export function VMSpecsFormat(row) {
  // 内存单位
  let res = row.coreKernel + ' CPU | ' + row.ramBitGb + ' GB <br/>'
  res += '系统盘：' + (row.sysDisk | 0) + 'GB ;外挂盘：' + (row.plugDisk | 0) + 'GB | ' + row.numDisk + ' 块'
  return res
}

/**
 * 解构后台返回的节点key，由四元组组成，分别为masterIp，namespace，workloadType和workloadName，以#间隔
 * @param key
 * @returns
 */
export const handleWorkloadKey = (key) => {
  const keyField = key?.split('#');
  return {
      masterIp: keyField[0] || '',
      namespace: keyField[1] || '',
      workloadKind: keyField[2] || '',
      workloadName: keyField[3] || '',
  }
}
// table搜索公共函数
export const handleTableSearch = (list, value, ...fields) => {
  let result = [];
  if (value.length > 0) {
    _.forEach(list, (item) => {
      if (
        _.some(
          fields,
          (field) =>
            item[field] && _.toLower(item[field]).indexOf(_.toLower(value)) > -1
        )
      ) {
        result.push(item);
      }
    });
  } else {
    result = [].concat(list);
  }
  return result;
};
